package com.system.util;

import org.springframework.beans.BeansException;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Repository;

@Repository
public class SpringApplicationUtil implements ApplicationContextAware{
	
    private static ApplicationContext context;  
	
	@Override  
    public void setApplicationContext(ApplicationContext context) throws BeansException {  
		SpringApplicationUtil.context = context;  
    }  
  
     
    public static Object getSpringBean(String beanName) {  
    	if(beanName==null){
    		System.out.println("beanName:null1");
    	}
        return context==null?null:context.getBean(beanName);  
    }  
  
    public static String[] getBeanDefinitionNames() {  
        return context.getBeanDefinitionNames();  
    }  

}
